<?php
/**
 * Created by PhpStorm.
 * User: yxs
 * Date: 2017/5/10
 * Time: 16:38
 */

namespace app\index\controller;

use icontroller\admin\AController;
use icontroller\admin\index\IAccount;
use logic\admin\index\LAccount;
use think\Cache;
use think\Controller;
use model\Account as mAccount;
use think\Db;
use think\Loader;

class Account extends AController implements IAccount
{

    private $logic;
    public function __construct()
    {
        parent::__construct();
        $this->logic=new LAccount();
    }

    public function index(){
        return view();
    }

    public function index_data()
    {
        $param=array(
            'search'=>input('search'),
            'limit'=>input('limit'),
            'offset'=>input('offset'),
            'ordinal'=>input('ordinal'),
            'order'=>input('order'),
            'status'=>input('status'),
            'begindate'=>input('begindate'),
            'enddate'=>input('enddate'),
        );
        $data=$this->logic->index_data($param);
        return $data;
    }

    public function add()
    {
        $accMo = new mAccount();
        $result = $accMo->cache(true,60)->select();
        print_r($result);die();
    }

    public function detail(){
        $id=input('id');
        $data=$this->logic->detail_data($id);
        $this->assign('data',$data);
        return view();
    }

    public function edit()
    {
        // TODO: Implement edit() method.
    }

    public function update()
    {
        $id=input('id');
        $param=array(
            'nick'=>input('nick'),
            'name'=>input('name'),
            'mobile'=>input('mobile'),
            'email'=>input('email'),
            'money'=>input('money'),
            'wechat'=>input('wechat'),
            'flag_lock'=>input('flag_lock'),
        );

        return $this->logic->update_data($id,$param);
    }

    public function delete()
    {
        $id=input('id');;
        return $this->logic->delete_data($id);
    }
    // <editor-fold defaultstate="collapsed" desc="修改角色">
    public function updaterole(){
        $id=input('id');
        $role_id=input('role_id');
        return $this->logic->update_role($id,$role_id);
    }
    // </editor-fold>

}